home *** CD-ROM | disk | FTP | other *** search
/ Computer Shopper 235 / Issue 235 - September 2007 - DPCS0907DVD.ISO / Extras / NetObjects Fusion / NOF10.exe / data1.cab / FSI / lib / nof / dialogs / Messages.js < prev    next >
Encoding:
Text File  |  2007-04-11  |  9.4 KB  |  242 lines

  1. /****i* SOURCE_FILE/INFO
  2. *
  3. * NAME
  4. * Messages.js
  5. *
  6. * USAGE
  7. *  Part of Netobjects JavaScript Library.
  8. *
  9. * COPYRIGHT
  10. *  Copyright ⌐ 2000-2005 Website Pros, Inc.
  11. *  All Rights Reserved.
  12. *
  13. *  This is an unpublished work protected by Website Pros, Inc.
  14. *  as a trade secret, and is not to be used or disclosed except as
  15. *  expressly provided in a written license agreement executed by
  16. *  you and Website Pros, Inc.
  17. *
  18. *      <copyright@websitepros.com>
  19. *
  20. * NOTES
  21. *  JavaScript code.
  22. *
  23. *****/
  24.  
  25. if (!IS.isModuleInitialized("IS.NOF.DIALOGS.Messages"))
  26. {
  27.   
  28.   /****h* NOF_JavaScript_Library/NOF.DIALOGS.Messages
  29.   *
  30.   * NAME
  31.   *  NOF.DIALOGS.Messages
  32.   *
  33.   * DESCRIPTION
  34.   *    
  35.   * The <code>Messages</code> class
  36.   * External dependencies: NOF.App, NOF.UTIL.PropertyResourceBundle
  37.   ****/
  38.   
  39.   /**
  40.   * constructor   
  41.   **/ 
  42.   function Messages() {
  43.     this.__proto__ = Messages.prototype;
  44.     this.installedPath = null;
  45.   }
  46.   {
  47.     var members = Messages.prototype;
  48.     
  49.     members.TITLE     = "TITLE";
  50.     members.TEXT      = "TEXT";
  51.     members.MODE      = "MODE";
  52.     members.INCLUDE_SKIP  = "INCLUDE_SKIP";
  53.     members.SKIP_KEY    = "SKIP_KEY";
  54.     members.SKIP_KEY_LABEL  = "SKIP_KEY_LABEL";
  55.     members.DETAILED_ALERTS = "DETAILED_ALERTS";
  56.     members.FEEDBACK_CONFIRM= "FEEDBACK_CONFIRM";
  57.     members.SIZE_WIDTH    = "SIZE_WIDTH";
  58.     members.SIZE_HEIGHT   = "SIZE_HEIGHT";
  59.     members.BUTTON_OK   = "BUTTON_OK";
  60.     members.BUTTON_CANCEL = "BUTTON_CANCEL";
  61.     
  62.     members.QUESTION    = "QUESTION";
  63.     members.WARNING     = "WARNING";
  64.     members.INFO      = "INFO";
  65.     members.NONE      = "NONE";
  66.     
  67.     members.IMAGE_NAME = {        
  68.       QUESTION  : "questionmark.gif",
  69.       WARNING   : "error.gif",
  70.       INFO    : "exclamation.gif",
  71.       NONE    : "pix.gif"
  72.     }
  73.     
  74.     //members.NOF_LABEL   = "NetObjects Fusion";
  75.     members.defaultProperties = null;    
  76.     
  77.     var method = Messages.prototype;
  78.     /** 
  79.     * prompt
  80.     * @param message text to be showed
  81.     * @param defaultValue default value entered in the edit field. 
  82.     * @param title dialog title.
  83.     * @param yesButtonLabel label for the first button (OK, Yes)
  84.     * @param noButtonLabel label for the second button (Cancel, No). If null, 
  85.     * the button will not be displayed.
  86.     * @param wnd window object (will be the parent of the new opened Messages dialog)
  87.     * @param width dialog with (in pixels)
  88.     * @param height dialog height (in pixels)
  89.     **/     
  90.     method.prompt = function (message, defaultValue, title, yesButtonLabel, noButtonLabel, wnd, width, height) {          
  91.       //(message, mode, detailedMessage, askAgainVar, askAgainLabel, title, yesButtonLabel, noButtonLabel, wnd, width, height, defaultFeedbackValue)
  92.       return this.messageBox(message, this.NONE, null, null, null, title, yesButtonLabel, noButtonLabel, wnd, width, height, defaultValue);
  93.     }
  94.     
  95.     /** 
  96.     * confirm
  97.     * @param message text to be showed
  98.     * @param askAgainVar a unique name to identify this message
  99.     * @param askAgainLabel text to be displayed next to the checkbox 
  100.     * (something like "Do not show this message again")
  101.     * @param title dialog title.
  102.     * @param yesButtonLabel label for the first button (OK, Yes)
  103.     * @param noButtonLabel label for the second button (Cancel, No). 
  104.     * If null, the button will not be displayed.
  105.     * @param wnd window object (will be the parent of the new opened Messages dialog)
  106.     * @param width dialog with (in pixels)
  107.     * @param height dialog height (in pixels)
  108.     **/     
  109.     method.confirm = function (message, askAgainVar, askAgainLabel, title, yesButtonLabel, noButtonLabel, wnd, width, height) {
  110.       return this.messageBox(message, this.QUESTION, null, askAgainVar, askAgainLabel, title, yesButtonLabel, noButtonLabel, wnd, width, height);
  111.     }
  112.     
  113.     /** 
  114.     * info
  115.     * @param message text to be showed
  116.     * @param askAgainVar a unique name to identify this message
  117.     * @param askAgainLabel text to be displayed next to the checkbox 
  118.     * (something like "Do not show this message again")
  119.     * @param title dialog title.
  120.     * @param buttonLabel label for the 'Close window' button (OK, Yes)      
  121.     * @param wnd window object (will be the parent of the new opened Messages dialog)
  122.     * @param width dialog with (in pixels)
  123.     * @param height dialog height (in pixels)
  124.     **/     
  125.     method.info = function (message, askAgainVar, askAgainLabel, title, buttonLabel, wnd, width, height) {          
  126.       this.messageBox(message, this.INFO, null, askAgainVar, askAgainLabel, title, buttonLabel, null, wnd, width, height);
  127.     }
  128.     
  129.     /** 
  130.     * warning
  131.     * @param message text to be showed
  132.     * @param askAgainVar a unique name to identify this message
  133.     * @param askAgainLabel text to be displayed next to the checkbox 
  134.     * (something like "Do not show this message again")
  135.     * @param title dialog title.
  136.     * @param yesButtonLabel label for the first button (OK, Yes)
  137.     * @param noButtonLabel label for the second button (Cancel, No). 
  138.     * If null, the button will not be displayed.
  139.     * @param wnd window object (will be the parent of the new opened Messages dialog)
  140.     * @param width dialog with (in pixels)
  141.     * @param height dialog height (in pixels)
  142.     **/     
  143.     method.warning = function (message, askAgainVar, askAgainLabel, title, yesButtonLabel, noButtonLabel, wnd, width, height) {         
  144.       return this.messageBox(message, this.WARNING, null, askAgainVar, askAgainLabel, title, yesButtonLabel, noButtonLabel, wnd, width, height);
  145.     }
  146.     
  147.     /** 
  148.     * alert
  149.     * @param message text to be showed      
  150.     * @param title dialog title.
  151.     * @param buttonLabel label for the 'Close window' button (OK, Yes)
  152.     * @param wnd window object (will be the parent of the new opened Messages dialog)
  153.     * @param width dialog with (in pixels)
  154.     * @param height dialog height (in pixels)
  155.     **/     
  156.     method.alert = function (message, title, buttonLabel, wnd, width, height) {         
  157.       this.messageBox(message, this.INFO, null, null, null, title, buttonLabel, null, wnd, width, height);
  158.     }
  159.     
  160.     /** 
  161.     * Show error/warning details in a textarea. 
  162.     * @param message text to be showed
  163.     * @param errorList Array of detailed messages.
  164.     * @param title dialog title.
  165.     * @param buttonLabel label for the 'Close window' button (OK, Yes)            
  166.     * @param wnd window object (will be the parent of the new opened Messages dialog)
  167.     * @param width dialog with (in pixels)
  168.     * @param height dialog height (in pixels)
  169.     */      
  170.     method.detailedAlert = function (message, errorList, title, buttonLabel, wnd, width, height) {          
  171.       this.messageBox(message, this.INFO, errorList.join("\r\n"), null, null, title, buttonLabel, null, wnd, width, height);
  172.     }
  173.     
  174.     method.messageBox = function (message, mode, detailedMessage, askAgainVar, askAgainLabel, title, yesButtonLabel, noButtonLabel, wnd, width, height, defaultFeedbackValue) {
  175.       
  176.       if ( (askAgainVar != null) && (NOF.App.getVariable(askAgainVar) == 'true') ) {
  177.         //alert("user said do not show this message again. "+askAgainVar);
  178.         return true;
  179.       }
  180.       
  181.       if (this.installedPath == null) {
  182.         this.installedPath = NOF.App.getSystemDirectory() + "/FSI/lib/nof/dialogs/";
  183.         //alert("installedPath "+this.installedPath);
  184.       }
  185.       
  186.       var args = new Array();
  187.       args[0] = NOF;
  188.       
  189.       var propObj =  new NOF.UTIL.PropertyResourceBundle("Messages.messageBox");
  190.       propObj.setProperty(this.TITLE, title || this.getDefaultProperty("label.defaultTitle"));
  191.       propObj.setProperty(this.TEXT, message);
  192.       propObj.setProperty(this.MODE, mode);
  193.       if (detailedMessage != null) {
  194.         propObj.setProperty(this.DETAILED_ALERTS, detailedMessage);
  195.       }
  196.       if (askAgainVar != null) {
  197.         propObj.setProperty(this.INCLUDE_SKIP, "true");
  198.         propObj.setProperty(this.SKIP_KEY, askAgainVar);
  199.         propObj.setProperty(this.SKIP_KEY_LABEL, askAgainLabel);
  200.       }
  201.       if (yesButtonLabel != null) {
  202.         propObj.setProperty(this.BUTTON_OK, yesButtonLabel);
  203.       }
  204.       if (noButtonLabel != null) {
  205.         propObj.setProperty(this.BUTTON_CANCEL, noButtonLabel);
  206.       }
  207.       
  208.       propObj.setProperty(this.SIZE_WIDTH, width);
  209.       propObj.setProperty(this.SIZE_HEIGHT, height);
  210.       
  211.       if (defaultFeedbackValue != null) {
  212.         propObj.setProperty(this.FEEDBACK_CONFIRM, defaultFeedbackValue);
  213.       }
  214.       
  215.       //propObj.setProperty(this., );
  216.       
  217.       args[1] = propObj;
  218.       
  219.       var wndw = (wnd != null) ? wnd : window;
  220.       var res = wndw.showModalDialog(this.installedPath + "MessageBoxDlg.html", args,
  221.         "status:no;help:no;border:thin;dialogWidth:" + width + "px;dialogHeight:"+ height + "px;center:yes;scroll:no;");
  222.       
  223.       //cleaning up explicitely some vars       
  224.       propObj = null;
  225.       
  226.       return res;
  227.       
  228.     }
  229.     
  230.     method.getDefaultProperty = function getDefaultProperty(propertyName) {
  231.       if (this.defaultProperties == null) {
  232.         this.defaultProperties = NOF.UTIL.ResourceBundle.getBundle("lib/nof/dialogs/DlgResources");
  233.       }
  234.     
  235.       return (this.defaultProperties != null) ? this.defaultProperties.getProperty(propertyName) : propertyName;
  236.     }
  237.   }
  238.   // add Messages to DIALOGS namespace
  239.   DIALOGS.__proto__.Messages = new Messages();
  240. }
  241.  
  242.